package 图.无向图;

import 图.深度优先遍历;
import 抽象数据类型.Graph;

/**
 * @description:
 * @author: ywk
 * @date: 2021-07-28
 */
public class 间隔的度数 {
    public static void main(String[] args) {
        String[][] actors = new String[][]{{"<<MEN WITH GUN>>", "david", "frank"}, {
                "<<SUN RISE IN THE EAST>>", "frank", "cindy"}, {"<<HIS LOVE HIS DREAM>>", "cindy", "david"}
        };
        符号图.SymbolGraph symbolGraph = new 符号图.SymbolGraph(actors);
        Graph g = symbolGraph.G();
        int start = symbolGraph.index("david");
        深度优先遍历.DepthFirstPaths dfs = new 深度优先遍历.DepthFirstPaths(g, start);

        String[] example = new String[]{"<<MEN WITH GUN>>", "cindy", "david"};
        for (String s : example) {
            int index = symbolGraph.index(s);
            System.out.println(s);
            if (dfs.hasPathTo(index)) {
                for (Integer v : dfs.pathTo(index)) {
                    System.out.println("\t" + ">>" + symbolGraph.name(v));
                }
            }
        }
    }
}
